package src.lab02.test21;

/**
 * Created by 林云志 on 2017/10/28.
 */
public class Test {
    public static void main(String[] args) {
        //21、 	统计一个字符串中给定字符出现的频率。

        String string = "asdfasdasa";
        char special = 'a';

        int number = 0;
        for (int i = 0; i< string.length(); i++){
            if (string.charAt(i) == special){
                number++;
            }
        }

        System.out.println("在字符asdfasdasa中 a出现的频率为："+number);
    }
    }

